'''
让控件拖动
1. dragEnterEvent
2. dropEvent
'''

import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

class DropDemo(QComboBox):
    def __init__(self):
        super().__init__()
        self.setAcceptDrops(True)

    def dragEnterEvent(self, e):
        print(e)
        if e.mineData().hasText():
            e.accept()
        else:
            e.ignore()
    def dropEvent(self, e):
        self.addItem(e.mineData().text())
class mainQ(QWidget):
    def __init__(self):
        super().__init__()
        formLayout = QFormLayout()
        formLayout.addRow(QLabel("#####"))

        linEdit = QLineEdit()
        linEdit.setDragEnabled(True)

        combo = DropDemo()
        formLayout.addRow(linEdit, combo)

        self.setLayout(formLayout)
        self.setWindowTitle("oooooooooo")
if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = mainQ()
    ex.show()
    sys.exit(app.exec_())